home *** CD-ROM | disk | FTP | other *** search
- Subject: Store a reference to another part
- Sent: 8/23/96 2:31 AM
- Received: 8/23/96 9:15 AM
- From: Steinar.Tyvand@si.sintef.no
- Reply-To: ODF Interest, ODF-Interest@CILabs.ORG
- To: OpenDoc Development Framework Discussion List, ODF-Interest@CILabs.
-
- I am making a part that needs to persistantly store a reference to another
- part in the same document.
- Will the following code work?
-
- Should I save the references in the kODPropContents property, adding a
- kODStrongStorageUnitRef value type to the property?
-
- Steinar
- //--------------------------------------------------------------
- // Persistant storage of pointers to other parts in the system
- ODPart* fOtherPart;
-
- // Externalize
- // Get the storage unit to the part
- ODStorageUnit otherSU = fOtherPart->GetStorageUnit(ev);
-
- // Get the StorageUnit ID
- ODStorageUnitID otherSUID = otherSU->GetID(ev);
-
- ODStorageUnitRef strongRef;
- FW_CByteArray byteArray(&strongRef, sizeof(ODStorageUnitRef));
-
- // Get a strong reference from the other storage unit
- suView->GetStrongStorageUnitRef(ev, otherSUID, strongRef);
-
- // Save it in this storage unit
- suView->SetValue(ev, byteArray);
-
-
- // Internalize
- ODStorageUnitRef strongRef;
- FW_CByteArray byteArray;
-
- // Read reference
- suView->GetValue(ev, sizeof(ODStorageUnitRef), byteArray);
- byteArray.CopyBuffer(&strongRef, sizeof(ODStorageUnitRef));
-
- if (!suView->IsValidStorageUnitRef(ev, strongRef))
- return FALSE;
-
- // Get ID of other StorageUnit
- ODStorageUnitID otherSUID = suView->GetIDFromStorageUnitRef(ev, aSURef);
-
- // Get the draft
- ODDraft* draft = suView->GetStorageUnit(ev)->GetDraft(ev);
-
- // Acquire other part
- fOtherPart = draft->AcquirePart(otherSUID);
-
-
-
- --------------------------------------------------------------
- Steinar Tyvand e-mail: Steinar.Tyvand@unimed.sintef.no
- SINTEF Unimed Rehab Phone: +47 22 06 78 29 (work)
- Box 124 Blindern Fax: +47 22 06 79 09 (work)
- N-0314 Oslo Phone: +47 67 56 17 79 (home)
- Norway Fax: +47 67 56 05 36 (home)
- --------------------------------------------------------------
-
-